/* 
 * Copyright 2012 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.appspot.dispotrains.station;

import com.google.common.collect.Sets;

import android.util.Pair;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

public class Station implements Serializable {
  public static interface Callback {
    public void execute(Station station);
  }

  public final Integer id;
  public final String name;
  private HashSet<Elevator> elevators = Sets.newHashSet();
  private HashSet<Integer> infomobiCodes = Sets.newHashSet();
  private HashSet<Line> lines = Sets.newHashSet();
  private Double latitude;
  private Double longitude;
  private String address;

  public Station(Integer id, String name) {
    this.id = id;
    this.name = name;
  }

  public void addInfomobiCode(int code) {
    this.infomobiCodes.add(code);
  }

  public Set<Integer> getInfomobiCodes() {
    return this.infomobiCodes;
  }

  public void addLine(Line line) {
    this.lines.add(line);
  }

  public Set<Line> getLines() {
    return this.lines;
  }

  public Pair<Double, Double> getCoordinates() {
    return Pair.create(latitude, longitude);
  }

  public String getAddress() {
    return this.address;
  }

  public void addElevator(Elevator elevator) {
    this.elevators.add(elevator);
  }

  public Set<Elevator> getElevators() {
    return this.elevators;
  }

  @Override
  public String toString() {
    return name;
  }

  @Override
  public int hashCode() {
    return id;
  }

  @Override
  public boolean equals(Object other) {
    if (!Station.class.isInstance(other)) {
      return false;
    }
    Station otherStation = (Station) other;
    return this.id.equals(otherStation.id);
  }
}
